Elevating Public Health Decision Making with R Packages

Kylie Ainslie

What if there was a better way?

Structure your project as an R package

The Framework

  • Step 1: Organize
  • Step 2: Document
  • Step 3: Share

June 2021 in the Netherlands

  • COVID-19 cases decreasing
  • Vaccination ongoing in adults
  • Relaxation of control measures

The Challenge

Question: Should the Netherlands extend COVID-19 vaccination to adolescents and children?

Timeline: ~2 weeks

Step #1: Organize

❌ Typical Project

├── analysis.R
├── analysis_v2.R  
├── FINAL_analysis.R
├── analysis_FINAL_v3.R
├── data_raw.csv
├── functions_maybe.R
├── temp_script.R
└── random_test.R

✅ Package Structure

📦 mypackage/
├── R/           # Code
├── data/        # Data  
├── man/         # Help files
└── vignettes/   # Analysis

Impact: Organization → Efficiency

  • 🔄 Models rapidly updated as new data became available
  • ⏰ Analysis delivered on time
  • 💉 Directly informed health policy decisions

Step #2: Document

❌ Separate Documents

├── analysis.R
├── methodology.docx
├── code_guide.pdf
├── final_report.pdf
├── final_report_FINAL.pdf
└── README.txt

✅ Integrated Package

📦 mypackage/
├── R/           # Code
├── man/         # Help files
└── vignettes/   # Docs + Reports
    └── analysis.Rmd → 📊 Report.pdf
                     → 🌐 Website

Vignettes = Dual Purpose

graph TD
    A[📖 analysis.Rmd] --> B[📋 Documentation<br/>for developers]
    A --> C[📊 Deliverable<br/>for clients]
    B --> D[pkgdown website]
    C --> E[PDF report]

Impact: Documentation → Transparency

  • 🛡️ Policy decisions backed by transparent analysis
  • 💡 Public could understand scientific basis for decisions
  • 🤝 More public trust

Step #3: Share

Steps 1-2

+

Sharing Platform

=

✨ Magic ✨

  • 📁 Standard Layout → Easy team handovers
  • 📖 Full documentation → Independent verification
  • ⚙️ Complete Package → Reusable tools

Sharing → Reproducibility

The pattern emerges: Organize → Document → Share

Three simple steps that transform analysis into lasting impact

Your Turn!

  • Try an R package structure for your next project
  • Tons of tools and learning materials available
  • You’ll never go back to messy folders
  • (Seriously, you’ll judge your past self)
  • (And maybe judge your colleagues’ folders too)

Announcement

I’ve just submitted my first R package to CRAN!

Get in touch!

  • LinkedIn: https://www.linkedin.com/in/kylieainslie/
  • BlueSky: @kylieainslie.bsky.social
  • GitHub: https://github.com/kylieainslie
  • Website: https://kylieainslie.github.io/